
 //   code
//
//  ViewController.m
//  LABEGCO
//
//  Created by STUDENT on 11/11/2556 BE.
//  Copyright (c) 2556 STUDENT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)handlebut:(id)sender {
    self.textbox.text=@"Hello";
}
- (IBAction)ration:(id)sender {
    self.textbox.text=@"rotation";}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)ggwp:(id)sender {
    self.textbox.text=@"doraemon";}


- (IBAction)savebut:(id)sender {
    NSFileManager* fm=[NSFileManager new];
    NSError* err=nil;
    NSURL* docURL=[fm URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:(YES) error:&err];
    
    NSString* filen=self.filename.text;
    NSString* data=self.wordstext.text;
    
    [data writeToURL:[docURL URLByAppendingPathComponent:filen]
           atomically:YES
             encoding:NSUTF8StringEncoding
                error:&err];
    
}
- (IBAction)loadbut:(id)sender {
    NSFileManager* fm=[NSFileManager new];
    NSError* err=nil;
    NSURL* docURL=[fm URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:(YES) error:&err];
    
    NSString* filen=self.filename.text;
    NSString* data=[NSString stringWithContentsOfURL:[docURL URLByAppendingPathComponent:filen] encoding:NSUTF8StringEncoding error:&err];
    self.wordstext.text=data;
    
}


- (BOOL)textFieldShouldReturn: (UITextField*) tf {
    [tf resignFirstResponder];
    return YES;
}
@end
